package com.maykk.Demo09;

public class Player {
    private String name;
    private int res;
    Player() {}
    Player(String name, int res) {
        this.name = name;
        if (res < 1 || res > 3) {
            System.out.println("出拳非法！！");
            System.exit(-1); // 出拳非法自定义退出码 -1
        }
        this.res = res;
    }

    public String getName() {
        return name;
    }

    public int getRes() {
        return res;
    }

    @Override
    public String toString() {
        String[] i = {"剪刀", "石头", "布"};
        return "Player{" +
                "name='" + name + '\'' +
                ", res=" + res +
                ",出拳=" + i[res - 1] +
                '}';
    }
}